package com.heyi.saas.start.service.impl;

import com.heyi.saas.start.constant.SaasConstant;
import lombok.extern.slf4j.Slf4j;
import com.heyi.saas.start.mapper.PublicMapper;
import com.heyi.saas.start.service.ShareDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author dengfeng
 * @Description: 共享数据的缓存服务
 * @date 2021/8/139:37
 */
@Slf4j
public class ShareDataServiceImpl implements ShareDataService {

    @Lazy
    @Resource
    private PublicMapper publicMapper;

    @Override
    @Cacheable(value = SaasConstant.SYS_SHARED_DATA_CACHE)
    public List<String> getIdList(String tableName) {

        List<String> mapList = publicMapper.getPublicItem("select id from " + tableName + " where tenant_id = 0");
        return mapList;
    }
}
